package utilities.event;

import java.util.Date;
import java.util.List;

import org.hibernate.Session;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Messagebox;

import utilities.Updatable;

public class NDIListener implements EventListener{
	private Datebox date;
	private Updatable updateItem;
	
	public NDIListener( Datebox date, Updatable updateItem ){
		this.date = date;
		this.updateItem = updateItem;
	}
	
	public void onEvent( Event event ){
		Date query = date.getValue();
		if( !checkDateValidation( query ) ){
			try{
				new Messagebox().show( "为定义的将来数据!" );
			}catch( InterruptedException exception ){
				/*  Ignore  */
			}					
			return;
		}
		
		updateItem.update( getData( query ), session );
	}
	
	
	private boolean checkDateValidation( Date query ){
		if( query.after( new Date() ) ){
			return false;
		}else{
			return true;
		}
	}
	
	//List中为List( 含字段"结账时间", "客人帐号", "登记时间", "客人类型", "总消费", "客人", "房号", "登记员", "结账员"
	//参数为请求查询的日期
	private List getData( Date query, Session session ){
		return null;
	}
}
